﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Tencent.OA.ACM.Entity.RouteInfoCondition>" %>

<%@ Import Namespace="Tencent.OA.ACM.Entity" %>
<%@ Import Namespace="Tencent.OA.ACM.App" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContainerPlaceHolder" runat="server">
    <div class="title ">
        路线列表
    </div>
    <%
        ControlDataSourceExtension controlDataProvider = new ControlDataSourceExtension();
        string display = "none";
        if (ViewData["hasCondition"] != null && ViewData["hasCondition"].ToString().Length>0)
            display="";
    %>
    <!--查询条件 Start-->
    <div id="condition" >
    <%
       using (Html.BeginForm("Index","Route",FormMethod.Get))
       {          
       
     %>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th>
                    路线名：
                </th>
                <td>
                    <%=Html.TextBoxFor(o=>o.RouteName) %>
                </td>
                <th>
                    城市：
                </th>
                <td>
                    <%=Html.DropDownListFor(o=>o.City, controlDataProvider.GetCity(true))%>
                </td>
                <th>
                    班车属性：
                </th>
                <td>
                    <%=Html.DropDownListFor(o=>o.BusType, controlDataProvider.GetBusType(true))%>
                </td>
            </tr>
            <tr>
                <th>
                    途经站点：
                </th>
                <td>
                    <%=Html.TextBoxFor(o=>o.SubSite) %>
                </td>
                <th>
                    站点坐标：
                </th>
                <td>
                    <%--<%=Html.TextBoxFor(o => o.BusNumber, new { onkeypress = "return inputNumber(event);" })%>--%>
                    <%=Html.DropDownListFor(o => o.LocationType, new List<SelectListItem>() { new SelectListItem() { Text = "----全部----", Value = "" },
                                                                                         new SelectListItem() { Text = "已匹配", Value = "0" },
                                                                                         new SelectListItem() { Text = "未匹配", Value = "1" }                                                                                       
                                                                                        })%>
                    </td>
                    <th>
                        运行方向：
                    </th>
                    <td>
                        <%=Html.DropDownListFor(o => o.BusDirection, new List<SelectListItem>() { new SelectListItem() { Text = "----全部----", Value = "" },
                                                                                         new SelectListItem() { Text = "上班方向", Value = "0" },
                                                                                         new SelectListItem() { Text = "下班方向", Value = "1" }                                                                                       
                                                                                        })%>
                </td>
            </tr>
            <tr>
                <th>
                </th>
                <td>
                    <input type="submit" name="submit" class="form_bot" value="查 询" style="width: 100px;" />
                </td>
                <td colspan="4">
                </td>
            </tr>
        </table>
            <%=this.Html.Hidden("condition_hidden",
            (ViewData["conditon"] == null) ? "" : ViewData["conditon"]
                       ) %>
        <%} %>
    </div>
    <!--查询条件 end-->
    <!--列表查询two-->
    <div class="list_title">
        <div class="pag_right">
        </div>
        <div style="padding-top: 6px;">
            <input type="button" value="查询" class="form_bot" id="btn_query" />
            <input type="button" value="新增" class="form_bot" onclick='window.location="<%=this.Url.Content("~/Route/Add") %>";' />
            <input type="button" value="删除" class="form_bot" onclick='return Delete();' />
            <input type="button" value="导出所有路线" class="form_bot" onclick="exportExcel()" />
            <%--   <input type="button" value="修改" class="form_bot" />
            <input type="button" value="删除" class="form_bot" />--%>
        </div>
    </div>
    <table id="myFault" class="tblData" cellpadding="0" cellspacing="0" style="width: 100%">
        <thead>
            <tr class="lt_head">
                <th style="width: 50px;">
                    <input type="checkbox" id="check_all" />
                </th>
                <th>
                    路线
                </th>
                <th>
                    <span style="width: 500px; vertical-align: top; word-break: break-all; word-wrap: break-word;">
                        路线信息</span>
                </th>
                <th>
                    台次
                </th>
                <th  style="width:100px;">
                    操作
                </th>
            </tr>
        </thead>
        <tbody id="gvList">
            <%
                IList<RouteInfo> list = this.Model.DataList.PagedList as IList<RouteInfo>;
                if (list == null || list.Count() == 0)
                {
            %>
            <%=this.Html.ListTableNoResultMessage(list,5) %>
            <%
                }
            %>
            <% foreach (var item in list)
               { %>
            <tr>
                <td>
                    <input type="checkbox" id="<%= item.RouteId %>" />
                </td>
                <td>
                    <a href="<%=this.Url.Content("~/Home/RouteView?rid="+item.RouteId) %>">
                        <%= item.RouteName %></a>
                </td>
                <td class="td_routedtl">
                    <div class="routetype">
                        <%= item.CityName %> --&nbsp; 
                        <%= item.BusTypeName %></div>
                         <div class="routetdtl">
                        <%= Tencent.OA.ACM.Controllers.StationInfoController.GetStationInfoByRouteID(item.RouteId) %>
                    </div>
                    <div class="routeattachinfo">
                        可容纳
                        <%= item.MaxPeoples %>
                        人，每<%= item.WorkingWeekDisp %>
                        运行
                    </div>
                      <div class="routeattachinfo" style=" width:430px; float:left; text-align:left;">
                          <a title="<%=item.Remark%>" style="text-decoration:none;"><%=string.IsNullOrEmpty(item.Remark)?"":"备注："+ Html.LimitStringLength(item.Remark,35)%></a>
                        </div>
                   
                </td>
                <td>
                    <%= item.BusNumber %>
                </td>
                <td>
                    <a href="<%=this.Url.Content("~/Route/Edit?RouteId="+item.RouteId) %>">编辑</a>&nbsp;|&nbsp;                   
                    <a href="#" onclick='return ShowEmpList("<%= item.RouteId %>","","<%=item.RouteName %>");'>人员</a>&nbsp;|&nbsp;
                    <a href="#" onclick='return sendNotice("<%= item.RouteId %>","<%=item.RouteName %>");'>通知</a>
                </td>
            </tr>
            <% } %>
        </tbody>
    </table>
    <!--翻页 Start-->
    <div class="paging">
        <%=Html.Pager(this.Model.DataList)%>
    </div>
    <!--翻页 End-->
    <script language="javascript" type="text/javascript">
       var recordIsEmpty=<%=list.Count() %>;
       
        $(document).ready(function() {
            $("#condition INput").attr("maxlength", "20")
        });
        //查看站点员工列表
        function ShowEmpList(rid, sid, sname) {
            var shortName=sname.length>10?sname.substr(0,10)+'...':sname;
            var reqUrl = '<%=this.Url.Content("~/Home/ViewEmpList?rid=' + rid + '&sid=' + sid + '")%>';
            showModel(reqUrl, shortName + '  人员列表', 500, 400);
            return false;
        }
        //发送路线通知
        function sendNotice(rid,sname){
            var reqUrl = '<%=this.Url.Content("~/Home/ViewSendNotice?rid=")%>'+ rid;
            var shortName=sname.length>10?sname.substr(0,10)+'...':sname;
            showModel(reqUrl, shortName + '  发送短信通知', 500, 323);
            return false;
        }
        
        function Delete() {

            var selectedRouteId = "";
            $("#gvList tr").each(function(index, row) {

                if ($(row).find("input[type=checkbox]").attr("checked")) {
                    selectedRouteId = selectedRouteId + "," + $(row).find("input[type=checkbox]").attr("id");
                }
            });

            if (selectedRouteId == "") {
                InfoTip.showMessage("请选择路线！",2);
            }
            else if (confirm("是否确定删除所选的一条或多条路线？")) {
                selectedRouteId=selectedRouteId.substring(1,selectedRouteId.length);
                
            //提交
             $.ajax({ 
                type: "POST",
                url: "<%=this.Url.Content("~/Route/DeleteByList") %>", 
                data: {"selectedRouteId":selectedRouteId},
                success: function(msg){
                        if(msg.StatuCode==0)
                        {
                             InfoTip.showMessage("删除成功！",1);
                             window.location.reload();
                        }                     
                    }
                });
            }
        }
//        //关闭模态对话框
//        function closeNoticeWindow()
//        {
//            showModel();
//        }

        
        //导出Excel
        function exportExcel() {
            if (recordIsEmpty==0) {
                alert("记录为空，无法导出Excel！");
                return;
            }
            window.frames[0].document.getElementById("excelType").value="2";
            window.frames[0].document.forms[0].submit();
        }    
    </script>
    
    <div style="display:none;"><iframe id="ifExportExcel" src="<%=this.Url.Content("~/Report/ExcelPost")%>"></iframe></div>      
    </script>
</asp:Content>
